//
//  OYAuthenticator.h
//  ObjectiveYouTube
//
//  Created by Tristan O'Tierney on 3/14/08.
//  Copyright 2008 Tristan O'Tierney. All rights reserved.
//

#import <ObjectiveYouTube/ObjectiveYouTube.h>

@interface OYAuthenticator : NSObject {
	id _delegate;
	NSURLConnection *_loginConnection;
	NSMutableData *_responseData;
	
	NSString *_username;
	NSString *_token;
	NSString *_clientID;
	NSString *_developerKey;
	NSString *_source;
	NSTimeInterval _timeoutInterval;
}

- (id)initWithDelegate:(id)delegate clientID:(NSString *)clientID developerKey:(NSString *)developerKey source:(NSString *)source;

// Login Control
- (void)cancelLogin;
- (void)loginAsUser:(NSString *)username withPassword:(NSString *)password;
- (void)logout;

// Accessors/Mutators
- (BOOL)isLoggedIn;
- (BOOL)isLoggingIn;

- (NSString *)username;
- (void)setUsername:(NSString *)username;

- (NSString *)token;
- (void)setToken:(NSString *)token;

- (id)delegate;
- (void)setDelegate:(id)delegate;

- (NSString *)clientID;
- (void)setClientID:(NSString *)clientID;

- (NSString *)developerKey;
- (void)setDeveloperKey:(NSString *)developerKey;

- (NSString *)source;
- (void)setSource:(NSString *)source;

- (NSTimeInterval)timeoutInterval;
- (void)setTimeoutInterval:(NSTimeInterval)timeoutInterval;
@end

// informal callback protocol
@interface NSObject (OYAuthenticatorDelegate)
- (void)authenticator:(OYAuthenticator *)auth succededWithToken:(NSString *)token;
- (void)authenticator:(OYAuthenticator *)auth failedWithError:(NSError *)error;
@end